package main

import (
	"time"
	"fmt"
)

func main() {
	//定时反复做事
	ticker := time.NewTicker(500 * time.Millisecond)
	//使用range通道中的 内建函数在每500毫秒到达一次时迭代值
	go func() {
		for t := range ticker.C {
			fmt.Println("tick at", t)
		}
	}()

	time.Sleep(1600 * time.Millisecond)
	ticker.Stop()
	fmt.Println("stop")

}
